﻿using SCM.Common;
using SqlSugar;
using System;

namespace SCM.Model
{
    /// <summary>
    /// 基础Entity 状态与日期
    /// </summary>
    public class EntityStatusAndDate
    {
        /// <summary>
        /// 数据状态
        /// </summary>
        protected DataStatusEnum _dataStatus = DataStatusEnum.Valid;

        /// <summary>
        /// 数据状态
        /// </summary>
        public virtual DataStatusEnum DataStatus
        {
            get { return _dataStatus; }
            set { _dataStatus = value; }
        }

        /// <summary>
        /// 数据状态字符串
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string DataStatusStr
        {
            get { return EnumHelper.GetDescription(DataStatus); }
        }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string CreateTimeStr { get { return CreateTime.HasValue ? CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : string.Empty; } }

        /// <summary>
        /// 最后编辑时间
        /// </summary>
        public DateTime? ModifyTime { get; set; }

        /// <summary>
        /// 最后编辑时间
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string ModifyTimeStr { get { return ModifyTime.HasValue ? ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : string.Empty; } }
    }

    /// <summary>
    /// 基础Entity
    /// </summary>
    public class EntityBase : EntityStatusAndDate
    {
        /// <summary>
        /// 创建人ID
        /// </summary>
        public string Creator { get; set; }

        /// <summary>
        /// 创建人名称
        /// </summary>
        public string CreatorName { get; set; }

        /// <summary>
        /// 最后编辑人ID
        /// </summary>
        public string ModifyUserId { get; set; }

        /// <summary>
        /// 最后编辑人名称
        /// </summary>
        public string ModifyUserName { get; set; }
    }
}
